package com.zthz.douxing.command

import com.zthz.douxing.utils.ValidateConstanst
import grails.validation.Validateable

/**
 * Created by zsw on 4/22/14.
 */
@Validateable
class DouXingFrequentContactCommand extends DouXingCommand {

    String name

    String mobileNo

    String address

    String seq

    static constraints = {

        name blank: false,nullable: false/*,validator: {

            value,command->

               if(FrequentContact.findByName(value)){

                   return "command.existUser"
               }

        }*/

        mobileNo blank: false,nullable: false,validator:{
            value,command->

                if(!ValidateConstanst.MobileNoPattern ==~ value)

                    return "command.mobileIncorrectFormate"

                /*else{

                    if(FrequentContact.findByMobileNo(value))

                        return "douXingRegisterCommand.exitsMobleNo"
                }*/


        }

        address blank: true,nullable: true

        seq blank: false,nullable: false


    }

}

@Validateable
class DouXingFrequentContactUpdateCommand extends DouXingCommand{

    String name

    String mobileNo

    String address

    String seq

    static constraints = {

        name blank: true,nullable: true

        mobileNo blank: true,nullable: true,validator: ValidateConstanst.MobileNo

        address blank: true,nullable: true

        seq blank: true,nullable: true

    }

}

@Validateable
class DouXingFrequentContactDeleteCommand extends DouXingCommand{


    static constraints = {

        uid blank: false,nullable: false

    }

}

@Validateable
class DouXingFrequentContactListCommand extends DouXingCommand{


    def gsonBuilder

    String  contacts_json

    static constraints = {

        contacts_json blank:false,nullable: false

    }

}